import scala.actors.Actor._

val sillyActor2 = actor {
  def haveBreak () {
    val mainActor = self
    actor {
      Thread.sleep(1000)
      mainActor ! "Wake up"
    }
  }

  var tmp = 0
//  haveBreak()

  loop {
    react {
      case "Wake up" =>
        println("I'm waking up!")
        tmp += 1
        if ( tmp < 5 )
            haveBreak()
      case msg =>
        println("Received: " + msg)
    }
  }

}
